
package com.songbl.bless.app.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songbl.bless.app.dao.ContactsDao;
import com.songbl.bless.app.dao.ContactsGroupDao;
import com.songbl.bless.app.entity.ContactsEntity;
import com.songbl.bless.app.entity.ContactsGroupEntity;
import com.songbl.bless.app.entity.UserAndGroupEntity;
import com.songbl.bless.app.form.ContractsGroupForm;
import com.songbl.bless.app.service.ContactsGroupService;
import com.songbl.bless.app.service.ContactsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  MVC:
 *   C:控制层调用 Service（业务层） ，service调用dao（持久层-由于mybatis不再写具体实现，直接使用）。
 *
 */
@Service("contactsService")
public class ContactsServiceImpl extends ServiceImpl<ContactsDao, ContactsEntity> implements ContactsService {

	@Autowired
	ContactsService contactsService;



	@Override
	public Boolean addContract(ContactsEntity contactsEntity) {
//		QueryWrapper queryWrapper  = new QueryWrapper();
//		queryWrapper.eq("contacts_id",contactsEntity.getContactsId());
		int insert = baseMapper.insert(contactsEntity);
		return insert==1;
	}

	@Override
	public Boolean deleteContract(ContactsEntity contactsEntity) {
		QueryWrapper queryWrapper  = new QueryWrapper();
		queryWrapper.eq("contacts_id",contactsEntity.getContactsId());
		int delete = baseMapper.delete(queryWrapper);
		System.out.println("删除联系人"+"" +delete);
		return delete==1;

	}

	@Override
	public Boolean updateContact(ContactsEntity contactsEntity) {
		QueryWrapper queryWrapper  = new QueryWrapper();
		queryWrapper.eq("contacts_id",contactsEntity.getContactsId());
		int update = baseMapper.update(contactsEntity,queryWrapper);
		return update==1;
	}


}
